<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>编辑商品信息</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
        <link rel="stylesheet" href="/static/css/xadmin.css">
		<link rel="stylesheet" href="/static/css/table.css">
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
		<script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery.form.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <form class="layui-form" id="signupForm" action="{:url('shop/goods/editgoods')}" method="post">
					<div class="layui-card">
                        <div class="layui-card-body">
                            <div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品编码</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									  <label class="layui-form-label">
										  <span class="x-red">*</span>产品编码
									  </label>
									  <div class="layui-input-inline">
										  <input type="text" name="goods_sn" required="" lay-verify="required" class="layui-input" value="{$goods.goods_sn}"/>
									  </div>
									  <div class="layui-form-mid layui-word-aux">
										  <span class="x-red">*</span>商品唯一标识
									  </div>
								  </div>
							  </div>
							</div>
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品信息</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品名称</label>
									  <div class="layui-input-inline">
										<input type="text" name="goods_name" id="goods_name" class="layui-input" value="{$goods.goods_name}"/>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">产品简称</label>
									  <div class="layui-input-inline">
										<input type="text" name="abbreviation" class="layui-input" value="{$goods.abbreviation}"/>
									  </div>
									</div>
								 </div>
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品分类</label>
									  <div class="layui-input-inline">
											<select name="category_id" lay-filter="zcate">
												<option value="">请选择产品分类</option>
												{volist name="fcat" id="vo"}
												<option value="{$vo.category_id}" {if condition="$vo.category_id eq $goods.category_id"}selected{/if}>{$vo.category_name}</option>
												{/volist}
											</select>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">产品子分类</label>
									  <div class="layui-input-inline">
											<select name="cat_id" id="cat_id" lay-filter="bute">
												<option value="">请选择产品子分类</option>
											</select>
									  </div>
									</div>
								 </div>
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品品牌</label>
									  <div class="layui-input-inline">
											<select name="brand_name" id="brand_name" lay-filter="attribute">
												<option value="">请选择产品品牌</option>
											</select>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">内存</label>
									  <div class="layui-input-inline">
											<select name="memory_name" id="memory_name" lay-filter="attribute">
												<option value="">请选择产品内存</option>
											</select>
									  </div>
									</div>
								 </div>
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品型号</label>
									  <div class="layui-input-inline">
											<input type="text" name="marker" class="layui-input" value="{$goods.marker}"/>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">属性</label>
									  <div class="layui-input-inline">
											<select name="attribute_name" id="attribute_name" lay-filter="attribute">
												<option value="">请选择产品属性</option>
											</select>
									  </div>
									</div>
								 </div>
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品颜色</label>
									  <div class="layui-input-inline">
											<select name="colour_name" id="colour_name" lay-filter="attribute">
												<option value="">请选择产品颜色</option>
											</select>
									  </div>
									</div>
								 </div>
								 <div class="layui-form-item layui-form-text">
									<label for="desc" class="layui-form-label">产品描述</label>
									<div class="layui-input-block">
										<textarea placeholder="请输入内容" name="describes" class="layui-textarea">{$goods.describes}</textarea>
									</div>
								</div>
							  </div>
							</div>
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品条形码</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									  <label class="layui-form-label">产品条形码</label>
									  <div class="layui-input-inline">
										  <input type="text" name="bar_code" class="layui-input" value="{$goods.bar_code}"/>
									  </div>
								  </div>
							  </div>
							</div>
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品价格</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">零售单价</label>
									  <div class="layui-input-inline">
										<input type="text" name="selling_price" class="layui-input" value="{$goods.selling_price}"/>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">批发价格</label>
									  <div class="layui-input-inline">
										<input type="text" name="trade_price" class="layui-input" value="{$goods.trade_price}"/>
									  </div>
									</div>
								 </div>
							  </div>
							</div>
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品提成</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">盈利提成</label>
									  <div class="layui-input-inline">
										<input type="text" name="profit_bonus" class="layui-input" value="{$goods.profit_bonus}"/>
									  </div>
									  <div class="layui-form-mid">%</div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label">营业额提成</label>
									  <div class="layui-input-inline">
										<input type="text" name="turnover_bonus" class="layui-input" value="{$goods.turnover_bonus}"/>
									  </div>
									  <div class="layui-form-mid">%</div>
									</div>
								 </div>
							  </div>
							</div>
							<div class="layui-tab layui-tab-card" style="margin-bottom:15px;">
							  <ul class="order_table">
								<li>产品预警</li>
							  </ul>
							  <div class="layui-tab-content">
								 <div class="layui-form-item">
									<div class="layui-inline">
									  <label class="layui-form-label">产品预警</label>
									  <div class="layui-input-inline">
										<input type="text" name="warning_number" class="layui-input" value="{$goods.warning_number}"/>
									  </div>
									</div>
									<div class="layui-inline">
									  <label class="layui-form-label" style="width:100px;">过期预警（天）</label>
									  <div class="layui-input-inline">
										<input type="text" name="warning_overdue" class="layui-input" value="{$goods.warning_overdue}"/>
									  </div>
									</div>
								 </div>
							  </div>
							</div>
							<div class="layui-tab-content">
								<div class="layui-form-item">
									  <input type="hidden" name="id" value="{$goods.goods_id}"/>
									  <button  class="layui-btn" lay-filter="add" lay-submit="">编辑</button>
								  </div>
							</div>
                        </div>
                    </div>
					</form>
                </div>
            </div>
        </div> 
		<script>
			var category_id = '{$goods.category_id}';
			var cat_id = '{$goods.cat_id}';
			var brand_name = '{$goods.brand_name}';
			var memory_name = '{$goods.memory_name}';
			var attribute_name = '{$goods.attribute_name}';
			var colour_name = '{$goods.colour_name}';
			layui.use(['form', 'layer'],
			function() {
				$ = layui.jquery;
				var form = layui.form,
				layer = layui.layer;

				function editgoods(category_id,cat_id,brand_name,memory_name,attribute_name,colour_name)
				{
					$.ajax({
						type: "POST",
						url: "/admin/category/lowerCate.html",
						cache: false, //禁用缓存
						data: {id:category_id}, //传入组装的参数
						dataType: "json",
						success: function (result) {
							console.log(result);
							var str = '<option value="">请选择产品子分类</option>';
							if(result.code==10001){
								var i;
								var info = result.option;
								for (i in info) {
									if(info[i].category_id == cat_id)
									{
										str += '<option value="'+info[i].category_id+'" selected>'+info[i].category_name+'</option>';
									}else{
										str += '<option value="'+info[i].category_id+'">'+info[i].category_name+'</option>';
									}
								}
								$('#cat_id').html(str);
								form.render('select');
							}
						},
						error:function () {
							layer.msg('网络错误', {icon: 5});
						}
					});
					$.ajax({
						type: "POST",
						url: "/admin/category/lowerBute.html",
						cache: false, //禁用缓存
						data: {id:cat_id}, //传入组装的参数
						dataType: "json",
						success: function (result) {
							console.log(result);
							var pingpai = result.pingpai;
							var neicun = result.neicun;
							var shuxing = result.shuxing;
							var yanse = result.yanse;
							var i;
							
							var pingpai_str = '<option value="">请选择产品品牌</option>';
							for (i in pingpai) {
								if(pingpai[i] == brand_name)
								{
									pingpai_str += '<option value="'+pingpai[i]+'" selected>'+pingpai[i]+'</option>';
								}else{
									pingpai_str += '<option value="'+pingpai[i]+'">'+pingpai[i]+'</option>';
								}
							}
							$('#brand_name').html(pingpai_str);
							
							var neicun_str = '<option value="">请选择产品内存</option>';
							for (i in neicun) {
								if(neicun[i] == memory_name)
								{
									neicun_str += '<option value="'+neicun[i]+'" selected>'+neicun[i]+'</option>';
								}else{
									neicun_str += '<option value="'+neicun[i]+'">'+neicun[i]+'</option>';
								}
							}
							$('#memory_name').html(neicun_str);
							
							var shuxing_str = '<option value="">请选择产品属性</option>';
							for (i in shuxing) {
								if(shuxing[i] == attribute_name)
								{
									shuxing_str += '<option value="'+shuxing[i]+'" selected>'+shuxing[i]+'</option>';
								}else{
									shuxing_str += '<option value="'+shuxing[i]+'">'+shuxing[i]+'</option>';
								}
							}
							$('#attribute_name').html(shuxing_str);
							
							var yanse_str = '<option value="">请选择产品颜色</option>';
							for (i in yanse) {
								if(yanse[i] == colour_name)
								{
									yanse_str += '<option value="'+yanse[i]+'" selected>'+yanse[i]+'</option>';
								}else{
									yanse_str += '<option value="'+yanse[i]+'">'+yanse[i]+'</option>';
								}
							}
							$('#colour_name').html(yanse_str);
							
							form.render('select');
						},
						error:function () {
							layer.msg('网络错误', {icon: 5});
						}
					})
				}
				editgoods(category_id,cat_id,brand_name,memory_name,attribute_name,colour_name);
			});
		</script>
		<script type="text/javascript" src="/static/customized/shop/addgoods.js"></script>
    </body>
</html>